/**
 * 
 */
package com.gmail.blackdog1987.onedollar.service.impl;

import com.gmail.blackdog1987.onedollar.dao.LuckyPanDao;
import com.gmail.blackdog1987.onedollar.entity.base.Page;
import com.gmail.blackdog1987.onedollar.service.LuckyPanService;
import com.gmail.blackdog1987.onedollar.util.JsonChangeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 * @author 董国超
 *
 */
@Service("luckyPanImpl")
public class LuckyPanImpl implements LuckyPanService {
	@Autowired
	private LuckyPanDao luckyPanDao;

	@Override
	public Map<String, Object> getList(Map<String, String> filter) {

		String userid = filter.get("userid");
		String pageIndex = filter.get("pageindex");
		String pageSize = filter.get("pagesize");

		int index = 1;
		int size = 10;
		if(pageIndex!=null&&pageIndex.length()!=0){
			index = Integer.valueOf(pageIndex);
			if(index<1){
				index = 1;
			}
		}
		if(pageSize!=null&&pageSize.length()!=0){
			size = Integer.valueOf(pageSize);
			if(size==0){
				size = 10;
			}
		}

		Page page = luckyPanDao.query(userid, index, size);

		return JsonChangeUtil.setResultJson(page).getResultMap();
	}
}
